Suppose a Student table has two columns, Name and Marks. How to get names and marks of the top three students.
How to get names and marks of the top three students.
366222-Sep-2021
Updated on 22-Sep-2021
Home / DeveloperSection / Forums / How to get names and marks of the top three students.
KIRTI SHARMA
03-Nov-2022We can get name and marks of top 3 students as follows:
SELECT TOP 3 * FROM table_name ORDER BY column_name;
Shivani
01-Oct-2022The names and marks of the top three students are obtained using a SELECT statement. The following SQL statement is used to determine the column in a table's given records with the highest value:
SELECT TOP N * FROM table_name ORDER BY column_name DESC;
You can write the query.
SELECT TOP 3* FROM students ORDER BY marks DESC;
if you want to learn more about databases, for example, Oracle Database you can join Oracle Online Course and solve these questions easily hope you like this
Ashutosh Kumar Verma
23-Sep-2021SQL SELECT Highest value:
To find the highest value from given records of column in a table then the following SQL statement is used for it,
SELECT TOP N * FROM table_name ORDER BY column_name DESC;
And find the min value from that table then,
SELECT TOP N * FROM table_name ORDER BY column_name ;(or ASC ;)
Example:
Lets have a database table ‘Students’ that store the record of students.
The following SQL statement is used to find the records of 3 students who get the highest marks.
select top 3 stuName, stuMarks from Students order by stuMarks desc;